import request from '@/utils/request'

// 创建销售订单
export function createOrder(data) {
  return request({
    url: '/api/sales-orders/',
    method: 'post',
    data
  })
}

// 获取订单列表
export function getOrders(params) {
  return request({
    url: '/api/sales-orders/',
    method: 'get',
    params
  })
}

// 获取订单详情
export function getOrderDetail(id) {
  return request({
    url: `/api/sales-orders/${id}/`,
    method: 'get'
  })
}

// 取消订单
export function cancelOrder(id) {
  return request({
    url: `/api/sales-orders/${id}/status/`,
    method: 'put',
    data: {
      status: 'cancelled',
      note: '客户取消订单'
    }
  })
}

// 更新订单状态
export function updateOrderStatus(id, data) {
  return request({
    url: `/api/sales-orders/${id}/`,
    method: 'put',
    data
  })
} 